package GUI;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JCheckBoxMenuItem;
import javax.swing.JInternalFrame;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;

public class ViewItem extends JCheckBoxMenuItem implements ActionListener,MenuListener {
	private JInternalFrame subjectFrame;
	
	private static final long serialVersionUID = 1L;
	public ViewItem(JInternalFrame subjectFrame){
		addActionListener(this);
		setSubjectFrame(subjectFrame);
	}
	public ViewItem(JInternalFrame subjectFrame,String text){
		addActionListener(this);
		setSubjectFrame(subjectFrame);
		setText(text);
	}
	
	@Override
	public void actionPerformed(ActionEvent ae) {
		getSubjectFrame().setVisible(getState());
	}
	public void setSubjectFrame(JInternalFrame subjectFrame){
		setState(subjectFrame.isVisible());
		this.subjectFrame=subjectFrame;
	}
	public JInternalFrame getSubjectFrame(){
		return subjectFrame;
	}
	@Override
	public void menuCanceled(MenuEvent e) {
		
		
	}
	@Override
	public void menuDeselected(MenuEvent e) {
		
		
	}
	@Override
	public void menuSelected(MenuEvent e) {
		setState(subjectFrame.isVisible());
	}
	
}
